<?php

class fValidatorEmail extends fValidator {
	public function __construct($options) {
		$this->setOption('pattern', '/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i');
		$this->addMessage('default', '"%value%" is not a email!');
		parent::__construct($options);
	}
	
	public function validate($value) {
		if (!preg_match($this->getOptions('pattern'), $value)) {
			$this->_failuresOptions[] = 'default';
			$this->addMessage('default', strtr($this->getMessage('default'), array('%value%' => $value)));
			
			return false;
		}
		
		return true;
	}
}